#include "UnknownFacetErr.h"

#include <stdarg.h>
#include <string.h>
#include <fan-llvm/core/Core.h>
#include "Str.h"
#include "Type.h"


Type* UnknownFacetErr_classType = NULL;
VTable* UnknownFacetErr_classVTable = NULL;


/**********************************************
 *
 * Methods and fields
 *
 **********************************************/


/* Void make(Str msg, Err? cause) */
void UnknownFacetErr_make_0(UnknownFacetErr* self)
{
  UnknownFacetErr_make(self, Str_defVal(), NULL);
}


/* Void make(Str msg, Err? cause) */
void UnknownFacetErr_make_1(UnknownFacetErr* self, Str* msg)
{
  UnknownFacetErr_make(self, msg, NULL);
}


/* Void make(Str msg, Err? cause) */
void UnknownFacetErr_make(UnknownFacetErr* self, Str* msg, Err* cause)
{
  Err_make((Err*)self, msg, cause);
}


/**********************************************
 *
 * Extra methods
 *
 **********************************************/


/* Create a new UnknownFacetErr instance and initialize it with UnknownFacetErr_make() */
UnknownFacetErr* UnknownFacetErr_new(Str* msg, Err* cause)
{
  UnknownFacetErr* err = (UnknownFacetErr*)Obj_allocate(sizeof(UnknownFacetErr), UnknownFacetErr_classVTable);
  UnknownFacetErr_make(err, msg, cause);
  return err;
}


/* Create a new UnknownFacetErr instance and initialize it with the message given by the specified format.
 * 'msgFormat' uses the same format as Str_newWithFormat() */
UnknownFacetErr* UnknownFacetErr_newWithFormattedMsg(const char* msgFormat, ...)
{
  va_list args;
  va_start(args, msgFormat);
  Str* msg = Str_newWithFormatValist(msgFormat, args);
  va_end(args);
  return UnknownFacetErr_new(msg, NULL);
}


/**********************************************
 *
 * Type-system functions
 *
 **********************************************/


Type* UnknownFacetErr_initType(void)
{
  if (UnknownFacetErr_classType == NULL)
  {
    Type* baseType = Err_initType();
    VTable* vtable = UnknownFacetErr_initVTable();
    Type* type = Type_new("UnknownFacetErr", baseType, vtable, sizeof(UnknownFacetErr), sizeof(UnknownFacetErrVTable));
    Type_registerCtorImplementation(type, "make", UnknownFacetErr_make_0, 0);
    Type_registerCtorImplementation(type, "make", UnknownFacetErr_make_1, 1);
    Type_registerCtorImplementation(type, "make", UnknownFacetErr_make, 2);
    UnknownFacetErr_classType = type;
    UnknownFacetErr_initStatic();
  }
  return UnknownFacetErr_classType;
}


VTable* UnknownFacetErr_initVTable(void)
{
  if (UnknownFacetErr_classVTable == NULL)
  {
    VTable* vtable = memoryAlloc(sizeof(UnknownFacetErrVTable));
    memcpy(vtable, Err_initVTable(), sizeof(ErrVTable));
    UnknownFacetErr_classVTable = vtable;
  }
  return UnknownFacetErr_classVTable;
}


void UnknownFacetErr_initStatic(void)
{
}
